package elven.d.web.action;

import java.util.HashMap;
import java.util.Map;
import java.util.Random;

import javax.servlet.http.HttpServletRequest;

import org.apache.commons.lang.math.RandomUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import elven.d.common.log.LogFactory;
import elven.d.web.event.hello.ContentEvent;
import elven.d.web.service.logs.LogsService;

@Controller
@RequestMapping("/logs")
public class LogsAction {

	@Autowired
	private LogsService logsService;
	
	@Autowired  
	private ApplicationContext applicationContext; 
	
	@ResponseBody
	@RequestMapping(value="/record")
	public Map<String, String> logs(HttpServletRequest request){
		try {
			applicationContext.publishEvent(new ContentEvent(" 添加日志 "));
		} catch (Exception e) {
			LogFactory.d().error(e.getMessage());
		}
		HashMap<String, String> out = new HashMap<String, String>();
		out.put(String.valueOf(RandomUtils.nextInt()), String.valueOf(RandomUtils.nextInt()));
		return out;
	}
	
}
